<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-03-10 23:49:19
 * @LastEditTime: 2022-03-11 00:01:17
 * @LastEditors: CHINAKAIYUAN
 * @Description: 点棍基础资料
 */


namespace App\Models;

use App\Traits\AutoCodeTrait;
use App\Traits\CommonUserTrait;

class PointStick extends BaseModel
    {
    use AutoCodeTrait;
    use CommonUserTrait;
    public $timestamps = true;
    public $table = "basedata_point_stick";
    protected $guarded = [];

    /**
     * 标识
     *
     * @var string
     */
    protected $ACSign = 'PointStick';

    public function useGlue($model = null)
        {
        $model = $model ?? $this;
        return 1000 / $model->has_quantity / $model->width;
        }
    public function category()
        {
        return $this->belongsTo(MaterialCategory::class);
        }
    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'table_status');
            });
        }

    }
